<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-col :span="8" :xs="24">
        <el-card class="box-card">
          
          <div>
            <div slot="header" class="clearfix">
            <span>个人信息</span>
          </div>
            <ul class="list-group list-group-striped">
              <li class="list-group-item">
                <svg-icon icon-class="user" />工号
                <div class="pull-right">{{ user.userName }}</div>
              </li>
              <li class="list-group-item">
                <svg-icon icon-class="user" />姓名
                <div class="pull-right">{{ user.empName }}</div>
              </li>
              <li class="list-group-item">
                <svg-icon icon-class="phone" />角色
                <div class="pull-right">{{ roleGroup.roleName }}</div>
              </li>
              <li class="list-group-item">
                <svg-icon icon-class="email" />职称
                <div class="pull-right">{{ user.title }}</div>
              </li>
              <li class="list-group-item">
                <svg-icon icon-class="tree" />部门
                <div class="pull-right-tree">{{ user.unitLabel }}</div>
              </li>
              <li class="list-group-item">
                <svg-icon icon-class="peoples" />邮箱
                <div class="pull-right">{{ user.email }}</div>
              </li>
              <li class="list-group-item">
                <svg-icon icon-class="date" />创建日期
                <div class="pull-right">{{ user.createTime }}</div>
              </li>
            </ul>
          </div>
        </el-card>
      </el-col>

      <el-col :span="16" :xs="24">
        <el-card>
          <div slot="header" class="clearfix">
            <span>部门权限</span>
          </div>
          <el-table  :data="priviList" >
          <el-table-column fixed label="序号" align="center">
            <template scope="scope">
              <span>{{scope.$index + 1}}</span>
            </template>
          </el-table-column>
          <el-table-column label="部门" :show-overflow-tooltip="true" align="center"  prop="label"  />
          <el-table-column label="部门编号" align="center" key="id" prop="id"  :show-overflow-tooltip="true" />
        </el-table>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import userAvatar from "./userAvatar";
import userInfo from "./userInfo";
import resetPwd from "./resetPwd";
import { getUserProfile } from "@/api/system/user";

export default {
  name: "Profile",
  components: { userAvatar, userInfo, resetPwd },
  data() {
    return {
      user: {},
      // 获取个人信息
      roleGroup: {},
      // 权限管理信息
      postGroup: {},
      activeTab: "userinfo",
      // 获取权限管理信息
      priviList:[],
      // 获取个人信息工号
      worknumber: "",
      // 获取个人信息姓名
      workname: "",
    };
  },
  created() {
    this.getUser();
  },
  methods: {
    getUser() {
      getUserProfile().then(response => {
        this.user = response.data;
        this.roleGroup = response.data.role;
        this.priviList = response.deptGroup;
        this.worknumber = response.data.empId;
        this.workname = response.data.empName;
        console.log(response.data);
        console.log(response.data.empId);
        console.log(response.data.empName);
      });
    }
  }
};
</script>
